package neuroBot.exploit.party;

import java.awt.Color;
import java.awt.Robot;

import neuroBot.exploit.KostenReader;
import neuroBot.exploit.Util;

//liest mit hilfe der PixelColors die Kosten aus
public class KostenReaderColor implements KostenReader {
	public int x1 = 154, y1 = 380;
	public int x2 = 282, y2 = 380;

	// 405
	public Robot rob;

	public KostenReaderColor() {
		try {
			rob = new Robot();
			rob.setAutoWaitForIdle(true);
		} catch (Exception e) {
			System.out.println(e);
		}
	}

	// 1 -> action
	// -1 -> nix
	// -2 -> i am back oder join waitlist
	public int getKosten(int tnr) {
		int[] xy = Util.getTableCoords(x1, y1, tnr);
		Color color = rob.getPixelColor(xy[0], xy[1]);
//		System.out.println(color);
		boolean buttonFold = color.getBlue() > 150 && color.getRed() < 75
				&& color.getGreen() < 155;
		xy = Util.getTableCoords(x2, y2, tnr);
		color = rob.getPixelColor(xy[0], xy[1]);
//		System.out.println(color);
		boolean buttonCall = color.getBlue() > 150 && color.getRed() < 75
				&& color.getGreen() < 155;
		if (buttonCall && buttonFold)
			return 1;
		if (buttonFold)
			return -2;
		return -1;
	}
}
